@extends('layouts.app')
@include('coupon.sidebar')
@section('content')
    <div class="content">
        <a class="btn btn-info btn-sm" href="{{ redirect()->back()->getTargetUrl() }}"> 返回 </a>
        <br />
        <br />
        {!! form($form) !!}
    </div>
@endsection
@push("stylesheets")
    <style>
        .select2-container--default .select2-selection--multiple .select2-selection__choice {
            color: gray;
        }
    </style>
@endpush
@push('scripts')
    <script>
        $('.search-user').select2({
            ajax: {
                dataType: 'json',
                delay: 250,
                url: function () {
                    return '{{ route('admin.search_user') }}';
                },
                processResults: function (data) {
                    return {
                        results: $.map(data, function(row, key) {
                            return {
                                id: key,
                                text: row
                            };
                        })
                    };
                }
            }
        });
        shopId = $('#shop_id').val();
        $('#shop_id').on('change', function () {
            shopId = $('#shop_id').val();
            $('.search-goods').html("");
        });
        $('.search-goods').select2({
            ajax: {
                dataType: 'json',
                delay: 250,
                url: function () {
                    return '{{ route('admin.search_shop_good') }}' + '?shop_id=' + shopId;
                },
                processResults: function (data) {
                    return {
                        results: $.map(data, function(row, key) {
                            return {
                                id: key,
                                text: row
                            };
                        })
                    };
                }
            }
        });
    </script>
@endpush
